$(function(){
	$('.theme-thumbnail').each(function(){
		var e = $(this);
		if(e.attr("title")=="") return;
		e.bt('<img src="'+e.attr("title")+'" width="400" height="300" />', 
		{
			width: 400, 
			height: 300,
			fill: 'white',
			strokeStyle: '#999',
			shrinkToFit: true,
			hoverIntentOpts: {interval: 0,timeout: 0}
		});
	});
});


function deleteTheme(iThemeID)
{
	if($("#star-"+iThemeID).attr("class")=="star-on")
	{
		alert("正在使用中的模板不能删除!");
		return;
	}
	
	if(confirm('本操作不可恢复, 确认要删除吗?'))
	{
		$.ajax({
			type: "GET",
			url: "./?app=template&task=ajax_delete&theme_id="+iThemeID,
			dataType: "json",
			success: function(json){
				if(json.status=="0")
				{
					$("#row-"+iThemeID).remove();
				}
				else
				{
					alert(json.description);
				}
			}
		});	
	}
}

function makeDefault(iThemeID)
{
	if($("#star-"+iThemeID).attr("class")=="star-on") return;
	$.ajax({
		type: "GET",
		url: "./?app=template&task=ajax_make_default&theme_id="+iThemeID,
		dataType: "json",
		success: function(json){
			if(json.status=="0")
			{
				$(".star-on").attr("class", "star-off").attr("title","点击启用此主题");
				$("#star-"+iThemeID).attr("class", "star-on").attr("title","已启用");
			}
			else
			{
				alert(json.description);
			}
		}
	});	
	
}